var app = require('../app')
	, order_helpers = require('../lib/aws_helpers')
  , request = require('supertest')
  , should  = require('should');

describe('Product Advertisement API', function() {
  describe('ItemLookup', function() {
    it('should return filtered products', function(done) {
      order_helpers.ItemLookup("B006UTVQAS", function(err, res) {
        //console.log(res);
				res.Items.should.be.a('object');
        done(err)
      })
    })
  })
})

describe('SimpleDB', function() {
	describe('ListDomains', function() {
		it('should return a list of domains', function(done) {
			order_helpers.ListDomains(function(err, res) {
				should.exist(res.ListDomainsResult);
				done(err)
			})
		})
	})

	describe('Select', function() {
		it('supports domain name', function(done) {
			order_helpers.Select({domain_name: 'orders'}, function(err, res) {
				//console.log(res.SelectResult["Item"][0]["Attribute"]);
				res.SelectResult.Item.should.be.an.instanceOf(Array);
				done(err)
			})
		})

		it('supports limit', function(done) {
			var q = {domain_name: 'orders', limit: 30};
			order_helpers.Select(q, function(err, res) {
				res.SelectResult.Item.should.be.an.instanceOf(Array);
				done(err)
			})
		})

		it('supports expression', function(done) {
			var q = {domain_name: 'orders', 'expr': {status: 'new'}};
			order_helpers.Select(q, function(err, res) {
				should.exist(res.SelectResult.Item);
				done(err)
			})
		})
	})
})
